home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-09 | 10.5 KB | 263 lines | [TEXT/MPS ] |
-
-
- Revision History
- ----------------
- 9 Dec 93 Renamed from UltraSlimFast to SourceObj to please Apple Legal Dept.
- 13 Oct 92 2.0a4 release
- 13 Oct 92 fix bug reading some records incorrectly
- 20 Aug 91 2.0a3 release
- 13 Aug 91 fix write to NIL bug
- 12 Aug 91 2.0a2 release
- 12 Aug 91 added Commando support, fix bug if source file does not end in CR
- 11 Aug 91 now read local label (type 18) records (e.g. labels in C)
- 29 July 91 2.0a1 release
-
-
-
- What is it?
- -----------
- SourceObj is an MPW 3.x tool that reads .o files to
- produce a nice listing of source and assembly side by side.
- It works with Pascal, C, ObjectPascal, and C++ sources.
-
- It is useful for learning how the MPW compilers generate code.
- UltraSlimFast 1.0 was used during the development of system 7.0 to
- reduce the code size of the system. It is also useful for people
- just learning assembly language, and it helps when you are in
- Macsbug.
-
- Note: UltraSlimFast 1.0 did not read .o files directly. You
- had to use DumpObj to a temp file, then UltraSlimFast would read
- that temp file. If you previously used UltraSlimFast 1.0, you will
- find this version much more convenient.
-
-
-
- How to I use it?
- ----------------
- To use it you will need to compile with SADE symbols on. All it
- really needs is SADE line info, so "-sym on,novars,notypes" will
- be slightly faster.
-
- The following is an example of how to use it and some sample output:
-
- Pascal Foo.p -sym on,novars,notypes
- SourceObj Foo.p.o
-
-
-
- What options are available?
- --------------------------------
-
- SourceObj [option…] objectFile > output ≥ progress
- -a # show hex opcodes for each asm line
- -class name # show all modules with this class name
- -f # don't show argument types in C++ unmangle names
- -i directory # search for source files
- -m name # only show this module (not case sensitive)
- -method name # show all modules with this method name
- -p # show progress info
- -symbols # show Macsbug names at end of modules
- -w # supress warning messages
-
- And now, in more detail:
-
- '-a' To save space, the hex opcodes for each assembly line is, by
- default, not shown. This force the hex opcodes to be shown.
-
- '-class name' Filters to only show modules for a specified class. Useful
- when using ObjectPascal or C++.
- Example: SourceObj MyOOPstuff.cp.o -class TDocument
-
- '-f' Unmangled C++ names tend to be long because they show the
- parameter types. This can make the disassembled code spill
- over into the source area. This option removes the parameter
- types. Example: "JSR Foo(short, long)" becomes "JSR Foo"
-
- '-i directory' A directory to search in when looking for source files.
-
- '-m name' Filters to show only one module. This is not particularly
- case sensitive, so Pascal programmers don't have to
- uppercase names like DumpObj requires.
-
- '-method name' Filters to only show modules of a specified method. Useful
- when using ObjectPascal or C++.
- Example: SourceObj MyOOPstuff.cp.o -method Free
-
- '-p' Shows random internal progress info. If you are really
- brave, try '-v' (verbose).
-
- '-symbols' Shows the bytes at the end of a module that MacsBug uses
- to show module names.
-
- '-w' Suppress warning messages.
-
-
-
-
- Are there any known problems?
- -----------------------------
- As of the alpha 1 release, this is the bugs I know about:
-
- Complicated "while" and "switch" statements in C can confuse SourceObj,
- resulting in misaligned output. (Actually, if you looked at the source
- records the MPW C compiler generates in those cases, you'd be confused too.)
-
- When using '-m name' with C++, you have to type the mangled name. Sorry.
-
- Imbedded string constants at the end of modules are not disassembled
- in a very smart way.
-
-
-
- What if I have suggestions, comments, or bug reports?
- -----------------------------------------------------
- Please send me any ideas or suggestions you have.
-
-
-
- What is the legal status of this?
- ---------------------------------
- This is not an official Apple product. I wrote it because I thought
- it would be useful. If you like it, feel free to pass this text file
- and the tool on to others.
-
-
- -Nick Kledzik
- 29 July 91
-
- AppleLink: NICK
- Internet: kledzik@apple.com
-
-
-
- How about some examples?
- ------------------------
-
-
- SourceObj :Objects:Procedure.cp.o -a -method GetBlankAsmLine
-
- 0000: 4E56 0000 LINK A6,#$0000 void TProcedure::GetBlankAsmLine(char* asmStr)
- 0004: 48E7 0308 MOVEM.L D6/D7/A4,-(A7) {
- 0008: 286E 000C MOVEA.L $000C(A6),A4 int asmWidth;
-
- 000C: 4A2D 0000 TST.B $0000(A5) if ( gShowOpcodes )
- 0010: 6704 BEQ.S $0016
- 0012: 7C30 MOVEQ #$30,D6 asmWidth = 48; // 48 = asm line width with opcodes
- 0014: 6002 BRA.S $0018 else
- 0016: 7C24 MOVEQ #$24,D6 asmWidth = 36; // 36 = asm line width without opcodes
-
- 0018: 7E00 MOVEQ #$00,D7 for (int i=0; i<asmWidth; i++)
- 001A: 6008 BRA.S $0024
- 001C: 18FC 0020 MOVE.B #$20,(A4)+ *asmStr++ = ' ';
- 0020: 2007 MOVE.L D7,D0
- 0022: 5287 ADDQ.L #$1,D7
- 0024: BC87 CMP.L D7,D6
- 0026: 6EF4 BGT.S $001C
- 0028: 4214 CLR.B (A4) *asmStr = '\0';
- 002A: 4CEE 10C0… MOVEM.L -$000C(A6),D6/D7/A4}
- 0030: 4E5E UNLK A6
- 0032: 4E75 RTS
- 0056: 0000 DC.W $0000
-
-
-
- SourceObj "{UEdition}.Debug Files:UEdition.p.o" -i "{UEdition}" -symbols -method Clone
-
- {$S ARes}
- FUNCTION TSection.Clone: TObject; OVERRIDE;
- VAR
- meToo: TSection;
- newSectionH: SectionHandle;
- newAliasH: AliasHandle;
- anErr: OSErr;
- 0000: LINK A6,#$FFF0 aliasWasChanged: BOOLEAN;
- 0004: MOVEA.L A7,A0 BEGIN
- 0006: MOVE.W #$0007,D0 { shallow clone }
- 000A: MOVE.W #$7267,(A0)+
- 000E: DBF D0,$000A
- 0012: MOVEM.L D6/D7/A2-A4,-(A7)
- 0016: JSR %_BP
- 001A: MOVE.L $0008(A6),D6
- 001E: MOVE.L #'rgrg',-(A7) meToo := TSection(INHERITED Clone);
- 0024: MOVE.L #'rgrg',-(A7)
- 002A: MOVE.L D6,-(A7) { clone SectionRecord }
- 002C: JSR TOBJECT_CLONE
- 0030: PEA $0034
- 0034: JSR %_OBCHK
- 0038: MOVEA.L (A7)+,A3
- 003A: MOVEA.L D6,A0 newSectionH := SELF.fSectionH;
- 003C: MOVEA.L (A0),A0
- 003E: MOVE.L $0006(A0),-$0008(A6)
- 0044: MOVE.W #$7267,-(A7) FailOSErr(HandToHand(Handle(newSectionH)));
- 0048: PEA -$0008(A6)
- 004C: JSR HANDTOHAND { clone AliasRecord }
- 0050: JSR FAILOSERR
- 0054: MOVEA.L D6,A0 newAliasH := SELF.fSectionH^^.alias;
- 0056: MOVEA.L (A0),A0
- 0058: MOVEA.L $0006(A0),A1
- 005C: MOVEA.L (A1),A1
- 005E: MOVE.L $0010(A1),-$000C(A6)
- 0064: MOVE.W #$7267,-(A7) FailOSErr(HandToHand(Handle(newAliasH)));
- 0068: PEA -$000C(A6)
- 006C: JSR HANDTOHAND { connect together }
- 0070: JSR FAILOSERR
- 0074: MOVEA.L -$0008(A6),A0 newSectionH^^.alias := newAliasH;
- 0078: MOVEA.L (A0),A0
- 007A: MOVE.L -$000C(A6),$0010(A0)
- 0080: MOVEA.L (A3),A0 meToo.fSectionH := newSectionH;
- 0082: MOVE.L -$0008(A6),$0006(A0)
- 0088: MOVEA.L -$0008(A6),A1 newSectionH^^.refCon := ORD(meToo);
- 008C: MOVEA.L (A1),A1
- 008E: MOVE.L A3,$000C(A1) { give clone a new SectionID }
- 0092: MOVEA.L $0002(A0),A4 WITH meToo.fDocument DO
- 0096: MOVEA.L (A4),A1 BEGIN
- 0098: MOVE.L $0094(A1),D0 fSectionIDcounter := fSectionIDcounter + 1;
- 009C: ADDQ.L #$1,D0
- 009E: TRAPV
- 00A0: MOVE.L D0,$0094(A1)
- 00A4: MOVEA.L -$0008(A6),A2 newSectionH^^.SectionID := fSectionIDcounter;
- 00A8: MOVEA.L (A2),A2 END;
- 00AA: MOVE.L $0094(A1),$0008(A2)
- { have it owned by no document }
- 00B0: MOVEQ #$00,D0 meToo.fDocument := NIL;
- 00B2: MOVE.L D0,$0002(A0)
- 00B6: MOVE.B $0000(A5),D0 IF gHasEditionManager THEN
- 00BA: BEQ.S $00FE
- 00BC: MOVE.W #$7267,-(A7) BEGIN
- 00C0: CLR.L -(A7) anErr := RegisterSection(FSSpecPtr(NIL)^,
- 00C2: MOVE.L -$0008(A6),-(A7) newSectionH, aliasWasChanged);
- 00C6: PEA -$000F(A6)
- 00CA: MOVE.W #$0604,D0
- 00CE: _Pack11
- 00D0: MOVE.W (A7)+,D7
- 00D2: TST.W D7 IF (anErr <> noErr)
- 00D4: SNE D0 & (anErr <> containerNotFoundWrn)
- 00D6: TST.B D0 & (anErr <> notThePublisherWrn)
- 00D8: BEQ.S $00FE
- 00DA: CMPI.W #$FE33,D7
- 00DE: SNE D1
- 00E0: AND.B D1,D0
- 00E2: BEQ.S $00FE
- 00E4: CMPI.W #$FE31,D7
- 00E8: SNE D1
- 00EA: AND.B D1,D0
- 00EC: BEQ.S $00FE
- 00EE: CMPI.W #$FE34,D7
- 00F2: SNE D1
- 00F4: AND.B D1,D0
- 00F6: BEQ.S $00FE
- 00F8: MOVE.W D7,-(A7) & (anErr <> multiplePublisherWrn) THEN FailOSErr(anErr);
- 00FA: JSR FAILOSERR {### should we warn user of duplicate publisher ??}
- END; {if}
-
- 00FE: MOVE.L A3,$000C(A6) Clone := meToo;
- 0102: JSR %_EP END; { Clone }
- 0106: MOVEM.L (A7)+,D6/D7/A2-A4
- 010A: UNLK A6
- 010C: MOVE.L (A7)+,(A7)
- 010E: RTS
- 0110: DC.B $80+$0E, 'TSECTION.CLONE', $00
- 0120: DC.W $0000
-
-